package com.zkthink.ceres.order.config;


import cn.hutool.core.lang.Snowflake;
import cn.hutool.core.util.IdUtil;
import com.zkthink.ceres.order.properties.KdNiaoProperties;
import com.zkthink.database.properties.DatabaseProperties;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
@EnableConfigurationProperties({DatabaseProperties.class})
public class SnowflakeConfiguration {

    @Bean
    public Snowflake initSnowflake(DatabaseProperties properties){
        DatabaseProperties.Id id = properties.getId();
        return IdUtil.getSnowflake(id.getWorkerId(), id.getDataCenterId());
    }

}
